<#include "../base.ftl"/>
<#macro cssfile>
</#macro>

<#macro scriptfile>
</#macro>

<#macro breadcrumb>
    <ul class="breadcrumb">
    <#include "../index-menu.ftl"/>
    <li class="active">舱单文件列表</li>
    </ul>
</#macro>

<#macro title>
广大物流云平台 
</#macro>

<#macro jsscript>
          

 
$(function(){
	$("#gridTable").jqGrid({
        
	
             
        //字典的url
	    dictUrl : 'optionList!options.action', 
	    //字典的key
	    dictCode: ["FEE_FLAG"],       
                       
        url : '${request.contextPath}/list/mainConsole/TSMCOSTList/list.html',  
        editurl : '${request.contextPath}/operator/tsm/TsmCost/operator.html',  
        datatype : "json",  
        mtype : 'POST',  
        height : 400,  
        colNames : ["航次", "费用类型","金额","费用标志","备注", "pk" ],  
        colModel : [ {  
        name : 'voyageId',  
        jsonmap : 'VOYAGE_ID',  
        index : 'VOYAGE_ID',
        hidden: true,  
        editable: true,  
        searchoptions : { sopt : [ "eq", "cn" ] },    search : true  
    },{  
        name : 'costType',  
        jsonmap : 'COST_TYPE',  
        index : 'COST_TYPE',  
        editable: true,  
        searchoptions : { sopt : [ "eq", "cn" ] },    search : true  
    },{  
        name : 'amount',  
        jsonmap : 'AMOUNT',  
        index : 'AMOUNT',  
        editable: true,  
        searchoptions : { sopt : [ "eq", "cn" ] },    search : true  
    },{  
        name : 'signFlag',  
        jsonmap : 'SIGN_FLAG',  
        index : 'SIGN_FLAG',  
        editable: true,  
        
        edittype:'select',
        formatter:'select',
        editoptions:{dictCode:"FEE_FLAG"},
      
        searchoptions : { sopt : [ "eq", "cn" ] },    search : true  
    },{  
        name : 'remark',  
        jsonmap : 'REMARK',  
        index : 'REMARK',  
        editable: true,  
        searchoptions : { sopt : [ "eq", "cn" ] },    search : true  
    },{  
        name : 'costId',  
        jsonmap : 'COST_ID',  
        index : 'COST_ID',  
        hidden: true,  
        editable: true,  
        searchoptions : { sopt : [ "eq", "cn" ] },    search : true  
    } ],  
    sortname : 'COST_ID',  
    sortorder : 'desc',  
    viewrecords : true,  
    gridview : true,  
    autowidth : true,  
    rowNum : 20,  
    rowList : [ 10, 20, 30 ],  
    pager : jQuery('#gridPager'),  
    jsonReader : {  
        page : "page.pageNo",  
        total : "page.totalPages",  
        records : "page.totalCount",  
        root : "page.result",  
        repeatitems : false,  
        id : 'COST_ID'  
    },      
    prmNames : {  
        rows : "page.pageSize",  
        page : "page.pageNo",  
        sort : "page.orderBy",  
        order : "page.order"  
    },  
    pager : "#gridPager",  
    caption : "费用登记"  
    }).navGrid('#gridPager', {  
        edit : true,  
        add : true,  
        del : true,  
        search : true  
    }, {  
            //edit  
            beforeShowForm : function(form) {  
            },  
            reloadAfterSubmit : true,  
            closeAfterEdit : true, //修改完毕后关闭  
            afterComplete : opertaionPrompt  
        }, {  
            //add  
            beforeShowForm : function(form) {  
            },  
            reloadAfterSubmit : true,  
            closeAfterAdd : true, //新增完毕后关闭  
            afterComplete : opertaionPrompt  ,
            onclickSubmit: fillVoyageId
        }, {  
            //del  
            reloadAfterSubmit : true,  
            afterComplete : opertaionPrompt  
        }, {  
            //组合查询  
            multipleSearch : true  
        });  
    });  



                                        
 //----------------------------                                       
jQuery(document).ready(function(){
	$.fn.zTree.init($("#shipTree"), setting);
});                                        
var setting = {
    async: {
        enable: true,
        url: '${request.contextPath}/costvoyage/costVoyageTree.action',
        datatype : 'json',
        autoParam:["id","name","pId","flag"]
    },
    data: {
        simpleData: {
               enable: true
        }
    },
    callback:{
        onNodeCreated : zTreeonNodeCreated,
        onClick:zTreeClick
    }
    
};                                    
 function zTreeonNodeCreated(event,treeId,treeNode){
    var treeObj=$.fn.zTree.getZTreeObj(treeId);
    var list=treeObj.getNodeByParam("level",'0');
    treeObj.expandNode(list,true,true,true);
 }
 function zTreeClick(event,treeId,treeNode){
      var a=treeNode.id;
      a=a.replace("B","");
	
	  jQuery("#gridTable").jqGrid('setGridParam',{
          url : "${request.contextPath}/list/mainConsole/TSMCOSTList/list.html?VOYAGE_ID="+a,
          page : 1 
      });
      jQuery("#gridTable").trigger('reloadGrid');
 }
 
 function fillVoyageId () {
  	 var treeObj=$.fn.zTree.getZTreeObj("shipTree");
      
      var nodes=  treeObj.getSelectedNodes();

      var add_data=new Object();

      var a=nodes[0].id;

      a=a.replace("B","");

      add_data["voyageId"]=a;

      return add_data;
 }
</#macro>


<#macro main>
    <div class="leftMaindiv">
	  	<div id="treediv" class="ui-widget-content ui-corner-all">
	       <ul id="shipTree" class="ztree"></ul>
	  	</div>
  	</div>
  
  	<div class="rightdetaildiv">
   		<table id="gridTable"></table>
       	<div id="gridPager"></div>
  	</div>
   
</#macro>